home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- ##############################################################################
- # Administration Script for NewsDude
- # This script is Copyright (c) 2000 by Perlboy.org, Stuart Low all rights
- # reserved. It may be used under the terms detailed in
- # http://www.perlboy.org/scripts/license.html
- #
- # YOU MAY MODIFY THIS SCRIPT PROVIDED YOU LEAVE THE ABOVE COPYRIGHT HEADING
- # INTACT.
- #
- # Other than that, enjoy the script. I did it mainly for a dude on
- # alt.www.webmaster but also just for a kick on my last day of exams.
- #
- # If you want to get in touch, mail me at thedude@perlboy.org
- # I WILL NOT ANSWER SUPPORT QUESTIONS THOUGH.
- # This is mainly done due to the fact that I am a school student
- # and therefore cannot afford to offer support for my free scripts.
- #
- # Once again. Visit alt.www.webmaster there are MANY a soul who will
- # happily help you.
- #
- #
- # If you own a business and use this on your clients sites
- # Could you please email me and tell me so that I can add your
- # business to a list of Web Design firms which use my script
- # Much appreciated
- #
- # Perlboy. (Stuart Low)
- # thedude@perlboy.org
- #
- # ------------------------------------------------------------------
- ##############################################################################
-
-
- # Load Settings
-
- require "vars.pl";
- require "subs.pl";
-
- # Set the home url of this script for any calls, notable the password login_html
- $admin_home='http://' . $ENV{'SERVER_NAME'} .
- ($ENV{'SERVER_PORT'} != 80 ? ":$ENV{'SERVER_PORT'}" : '') .
- $ENV{'SCRIPT_NAME'} . $ENV{'PATH_INFO'} .
- (length ($ENV{'QUERY_STRING'}) ? "?$ENV{'QUERY_STRING'}" : '');
- ###
-
-
-
- print "Content-Type: text/html\n\n";
-
- &FormParse;
-
- # Check if Logout is the command, different position to stop looping
- if (($FORM{'operation'}) eq 'Logout') { &login_html; exit; }
-
- # Password checking processs, checks every time executed, top security.
-
- if (!$FORM{'login_password'}) { &login_html; exit; }
-
-
- if ($FORM{'login_password'} ne $adminpassword) { &error_html("Wrong password"); }
-
- &Date;
- # Load some files
-
- open(NEWS, "news.arch");
- @DelMe=<NEWS>;
- close(NEWS);
-
- ### Now check for commands
-
- # Check for news updates
- if ((($FORM{'operation'}) eq 'Add News') and (($FORM{'news_command'}) eq 'Add')) { &News_Add; exit; }
- if (($FORM{'operation'}) eq 'Add News') { &News1; exit; }
-
- # Check for Deleting News
- if ((($FORM{'operation'}) eq 'Delete News') and (($FORM{'news_command'}) eq 'DeleteYes')) { &news_Del2; exit; }
- if (($FORM{'operation'}) eq 'Delete News') { &news_Del1; exit; }
-
- # If no matches print out the good ol' default page.
- print qq~
-
- <html>
- <head>
- <title>Admin Section</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
-
- <body background="http://www.amiganorththames.co.uk/Gfx/bg_stripe.gif" text="#000000" link="#DD3300">
-
- <form method="POST"><input type="hidden" name="login_password" value="$FORM{'login_password'}"><input type="hidden" name="username" value="$FORM{'username'}">
-
-
- <br><center> Welcome $pa_column1{$FORM{'username'}} to the admin section. <BR><br>
-
- <table border=0 width=200 ALIGN=CENTER>
- <tr>
- <td><input type="submit" name="operation" value="Add News"></td> </td>
- <td><input type="submit" name="operation" value="Delete News"></td> </td>
- </tr>
- </table>
-
- <BR>
- <TABLE WIDTH=70% ALIGN=RIGHT BORDER=0 CELLSPACING=0 CELLPADDING=1>
- <TR>
- <TD COLSPAN=2 ALIGN=LEFT>
- Your current details are<br>
- </TD>
- </TR>
-
- <TR>
- <TD WIDTH=100 ALIGN=RIGHT>
- <B>Real Name:</B>
- </TD>
- <TD>
- $adminrealname
- </TD>
-
- </TR>
- <TR>
-
- <TD WIDTH=100 ALIGN=RIGHT>
- <B>Email Address:</B>
- </TD>
- <TD>
- $adminemailaddress
- </TD>
-
- </TR>
- <TR>
-
- <TD WIDTH=100 ALIGN=RIGHT>
- <B> Username:</B>
- </TD>
- <TD>
- $adminusername
- </TD>
-
- </TR>
- <TR>
-
- <TD WIDTH=100 ALIGN=RIGHT>
- <B> Password: </B>
- </TD>
- <TD>
- $adminpassword
- </TD>
- </TR>
- </TABLE>
-
- ~;
-
- # Print the footers
- print qq~
-
- </body></html>
-
- ~;
-
- sub News1 {
-
-
- print qq~
-
- <HTML>
- <BODY BACKGROUND="http://www.amiganorththames.co.uk/Gfx/bg_stripe.gif">
-
- <center>
- <font face="arial, helvetica" color=red size=+1>
- <strong>Update News<br><br></strong></font></font></font>
- </center>
- <form method=POST><input type="hidden" name="login_password" value="$FORM{'login_password'}"><input type="hidden" name="username" value="$FORM{'username'}"><input type="hidden" name="operation" value="Add News">
-
-
-
- <table border=0 width=60% ALIGN=CENTER>
-
- <tr>
-
- <td align=CENTER>
- <B>Posted On:</B> $todays_date
- </td>
-
- </TR>
-
- <TR>
- <td align=CENTER>
- <B>Post by:</B> $FORM{'username'}
- </td>
-
- </tr>
-
- </TABLE>
-
- <BR>
- <table border=0 width=95% ALIGN=CENTER>
- <tr>
- <td width=100 valign=top align=RIGHT><b>Title: </b></td>
- <td><INPUT TYPE=text name=title size=30></td>
- </tr>
-
- <tr>
- <td width=100 valign=top align=RIGHT><b>News: </b></td>
- <td><textarea rows=20 name=item cols=80></textarea></td>
- </tr>
- <tr>
-
- <td COLSPAN=2 ALIGN=CENtER><input type=submit value=Add name=news_command></td>
- </tr>
- </table>
- <br><br>
- </BODY>
- </HTML>
-
- ~;
-
- }
-
- sub News_Add {
-
- open(NEWSFILE, "news.arch");
- @OldNews=<NEWSFILE>;
- close(NEWSFILE);
-
- $newline='<br>';
-
- $FORM{'item'} =~ s/\r//g;
- $FORM{'item'} =~ s/\n/$newline/g;
-
-
- $html .= "$FORM{'username'}|$todays_date|$FORM{'title'}|$FORM{'item'}\n";
- foreach $line (@OldNews) {
- $html .= "$line";
- }
-
- open(NEWSFILE, ">news.arch");
- print NEWSFILE "$html";
- close(NEWSFILE);
-
-
- print qq~
- <HTML>
- <BODY BACKGROUND="http://www.amiganorththames.co.uk/Gfx/bg_stripe.gif">
-
- <center>
- <font face="arial, helvetica" color=red size=+1>
- <strong>News Updated<br><br></strong></font></font></font>
- <form method=POST><input type="hidden" name="login_password" value="$FORM{'login_password'}"><input type="hidden" name="username" value="$FORM{'username'}"><input type="hidden" name="operation" value="News"><br><br>
- Hey! News is Updated Dude.
- <input type=submit value="Return to Main" Add name=operation>
- </BODY>
- </HTML>
-
- ~;
-
- }
-
-
- sub news_Del1 {
-
- $recordno='1';
-
- foreach $line (@DelMe) {
-
- ($Nick,$time,$title,$message) = split(/\|/,$line);
- $email=$adminemailaddress;
-
- print qq~
- <HTML>
- <BODY background="http://www.amiganorththames.co.uk/Gfx/bg_stripe.gif" text="#000000" link="#DD3300">
-
-
- <table width=95% border=0 ALIGN=CENTER CELLPADDING=1 CELLSPACING=0>
-
- <TR>
- <TD COLSPAN=2 ALIGN=CENTER>
- <HR WIDTH=98%>
- </TD>
- </TR>
-
- <tr>
-
- <td WIDTH=100 ALIGN=RIGHT>
- <B>Subject: </B>
- </TD>
-
- <td ALIGN=LEFT WIDTH="*">
- <font size=+1>$title</font>
- </td>
-
- </tr>
-
- <TR>
-
- <TD ALIGN=RIGHT>
- <B> Date: </B>
- </TD>
-
- <TD ALIGN=LEFT VALIGN=MIDDLE>
- $time
- </TD>
-
- </TR>
-
- <tr>
-
- <TD></TD>
-
- <td>
- $message
- </td>
-
- </tr>
-
- <TR>
- <TD COLSPAN=2 ALIGN=CENTER>
- <HR WIDTH=98%>
- </TD>
- </TR>
-
- <TR>
-
- <TD COLSPAN=2 ALIGN=CENTER>
-
- <form method=POST>
- <input type="hidden" name="login_password" value="$FORM{'login_password'}">
- <input type="hidden" name="username" value="$FORM{'username'}">
- <input type="hidden" name="operation" value="Delete News">
- <input type="hidden" name="news_command" value="DeleteYes">
- <input type="hidden" name="deletethis" value="$recordno">
- <input type=submit value="Delete">
- </form>
-
- </td>
-
- </tr>
-
- </table>
-
-
-
- <br>
- </BODY></HTML>
-
- ~;
-
- $recordno = $recordno + 1;
-
-
- }
- }
-
- sub news_Del2 {
-
- print "$FORM{'deletethis'} <br>";
-
- $recordno = '1';
-
- foreach $line (@DelMe) {
-
- ($Nick,$time,$title,$message) = split(/\|/,$line);
- $email=$adminemailaddress;
-
- if($recordno eq $FORM{'deletethis'}) {
- }
- else {
- $newsfile .="$Nick|$time|$title|$message";
- }
-
- $recordno = $recordno + 1;
-
- }
-
- open(NEWSFILE, ">news.arch");
- print NEWSFILE "$newsfile";
- close(NEWSFILE);
-
- print qq~
- <HTML>
- <BODY BACKGROUND="http://www.amiganorththames.co.uk/Gfx/bg_stripe.gif">
-
- <center>
- <font face="arial, helvetica" color=red size=+1>
- <strong>News Deleted<br><br></strong></font></font></font>
- <form method=POST><input type="hidden" name="login_password" value="$FORM{'login_password'}"><input type="hidden" name="username" value="$FORM{'username'}"><input type="hidden" name="operation" value="News"><br><br>
-
- <b><center>News Post Removed</center></b>
- <input type=submit value="Return to Main" name=operation>
- </BODY>
- </HTML>
-
- ~;
-
-
-
-
- }
-